//
// Created by Zhang on 2022/4/1.
//

#include <iostream>
#include <string>

//chapter 2 extra q3
class Clerk {
private:
    std::string name;
    long phone_number;
    std::string email;
    bool type;
    static std::string remark;
    int id;
    static int all;
public:
    Clerk(std::string, long);

    Clerk(std::string, std::string);

    static void set_id(Clerk people, int ID = -1);

    friend void call(Clerk people);

};

Clerk::Clerk(std::string clerk_name, long number) {
    name = clerk_name;
    phone_number = number;
    type = true;
}

Clerk::Clerk(std::string clerk_name, std::string mail) {
    name = clerk_name;
    email = mail;
    type = false;

}

void call(Clerk people) {
    if (people.type) {
        std::cout << "you can call " << people.name << " by phone:" << people.phone_number << std::endl;
    } else {
        std::cout << "you can call " << people.name << " by email:" << people.email << std::endl;
    }
}

void Clerk::set_id(Clerk people, int ID) {
    static int all = 0;
    if (ID == -1) {
        people.id = all++;
    } else {
        all++;
        people.id = ID;
    }
}

// chapter 3 extra q1
class CPerson {
private:
    std::string name;
    int ID;
    bool gender;
public:
    void set_info(std::string n, int id, bool gen);

    void show();
};

void CPerson::set_info(std::string n, int id, bool gen) {
    name = n;
    ID = id;
    gender = gen;
}

void CPerson::show() {

    std::cout << name << " " << ID;
    if (gender) {
        std::cout << " male" << std::endl;
    } else {
        std::cout << " female" << std::endl;
    }
}

class Cstudent : public CPerson {
private:
    int score;
public:
    void set_info(std::string n, int id, bool gen, int s);

    void show();
};

void Cstudent::set_info(std::string n, int id, bool gen, int s) {
    CPerson::set_info(n, id, gen);
    score = s;
}

void Cstudent::show() {
    CPerson::show();
    std::cout << score << std::endl;
}

class CTeacher : public CPerson {
private:
    int age;

public:
    void set_info(std::string n, int id, bool gen, int s);

    void show();
};

void CTeacher::set_info(std::string n, int id, bool gen, int s) {
    CPerson::set_info(n, id, gen);
    age = s;
}

void CTeacher::show() {
    CPerson::show();
    std::cout << age << std::endl;

}


int main() {

    Clerk a("1", 12345678), b("2", "1@cpp.com");
//    a.init();
    call(a);
    call(b);
//    a.info();
    a.set_id(a);
    b.set_id(b);
//    b.info();

// chapter 3 extra q1
    CPerson p;
    p.set_info("name", 2, 0);
    p.show();
    Cstudent s;
    s.set_info("st", 3, 1, 100);
    s.show();
    CTeacher tt;
    tt.set_info("tt", 5, 0, 20);
    tt.show();


    return 0;
}